import request from "@/request";
import { AxiosResponse } from "axios";
import ResultEnum from "@/config/ResultEnum";
import { message } from "ant-design-vue";

export const statusOptions = [
  {
    label: "正常",
    value: "Normal",
    color: "#2db7f5",
  },
  {
    label: "禁用",
    value: "Disable",
    color: "#87d068",
  },
];

//表格列
export const tableCols = [
  {
    title: "#",
    dataIndex: "idx",
    key: "idx",
    width: 50,
  },
  {
    title: "昵称",
    dataIndex: "nickName",
    key: "nickName",
  },
  {
    title: "姓名",
    dataIndex: "realName",
    key: "realName",
  },
  {
    title: "电话",
    dataIndex: "phone",
    key: "phone",
  },
  {
    title: "生日",
    dataIndex: "birthday",
    key: "birthday",
  },
  {
    title: "性别",
    dataIndex: "sex",
    key: "sex",
  },
  {
    title: "OpenID",
    dataIndex: "miniProgramOpenId",
    key: "miniProgramOpenId",
  },
  {
    title: "状态",
    key: "status",
    dataIndex: "status",
  },
  {
    title: "创建时间",
    key: "createdTime",
    dataIndex: "createdTime",
  },
  {
    title: "操作",
    width: "240px",
    key: "actions",
  },
];

//获取数据
export const loadTable = (params: any) => {
  return new Promise((resolve: any, reject: any) => {
    request({
      url: "/member/list",
      method: "get",
      params,
    }).then((res: any) => {
      if (res.code == ResultEnum.SUCCESS_CODE) {
        resolve(res.result);
      } else {
        message.error(res.message);
      }
    });
  });
};
